import Rasterizer

#if no object is selected, return immediately.
if GameLogic.selectedObject != None:

	# get controller
	cont = GameLogic.getCurrentController()

	target = GameLogic.selectedObject #as defined in object_selection script
	target_pos = target.getPosition()

	mouseOverAny = cont.getSensor("mouseOverAny")

	if mouseOverAny.isPositive():
		hit_pos = mouseOverAny.getHitPosition() #return the 3D point which is "touched" by the mouse

		#change the X and Z position of the selected object. Y is kept. So this script is
		# "usable" only if the CameraUser looks roughly at the (X,Z) plan.
		target.setPosition([hit_pos[0], target_pos[1], hit_pos[2]])
